package daily.mar0326;

import java.io.IOException;

class Student {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws IOException {
        if (age < 0) {
            throw new IOException("年龄怎么会小于0啊");
        }
        this.age = age;
    }

    void spack() {
        System.out.println(name + "今年" + age + "岁");
    }
}

public class StudentClassTest {
    public static void main(String[] args) throws IOException {
        Student s1 = new Student();
        Student s2 = new Student();
        Student s3 = new Student();
        s1.setName("张三");
        s1.setAge(-1);
        s1.spack();
        s2.setName("李四");
        s2.setAge(4);
        s2.spack();
        s3.setName(s2.getName());
        s3.setAge(s2.getAge());
    }
}
